﻿
using Bootstrap5.Abstractions;

using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Rendering;

namespace Bootstrap5;

public class ButtonGroup : BootstrapChildContentComponentBase
{
    [Parameter] public bool ToolBar { get; set; }
    [Parameter][CssClass("btn-group-vertical")] public bool Vertical { get; set; }
    [Parameter][CssClass("btn-group-")] public Size? Size { get; set; }

    protected override void CreateCssClass(ICssClassBuilder builder)
    {
        builder.Add("btn-group", !ToolBar)
            .Add("btn-toolbar", ToolBar)
            ;
    }

    protected override void BuildExtraAttributes(RenderTreeBuilder builder, int sequence = 5)
    {
        var role = "group";
        if (ToolBar)
        {
            role = "toolbar";
        }
        builder.AddAttribute(sequence++, "role", role);
    }
}
